export class http {
    static baseUri = '//' + location.hostname + ":9000";
    static request(t) {
        if (t.startsWith('http') || t.startsWith('//')) {

        }
        else {
            t = http.baseUri + t;
        }
        var e = new XMLHttpRequest;
        return new Promise(function (n, i) {
            e.onreadystatechange = function () {
                4 === e.readyState && (e.status >= 200 && e.status < 300 ? n(e.response) : i(new Error("Request failed with status " + e.status)))
            }
                ,
                e.open("GET", t, !0),
                e.send()
        }
        )
    }
    static post(t, d) {
        if (t.startsWith('http') || t.startsWith('//')) {

        }
        else {
            t = http.baseUri + t;
        }
        var e = new XMLHttpRequest;
        return new Promise(function (n, i) {
            e.onreadystatechange = function () {
                4 === e.readyState && (e.status >= 200 && e.status < 300 ? n(e.response) : i(new Error("Request failed with status " + e.status)))
            }
                ,
                e.open("POST", t, !0),
                e.send(JSON.stringify(d))
        }
        )
    }
}